build: enable CA2007 enforcement via nested src/.editorconfig#5230
Draft
jamescrosswell wants to merge 1 commit into
Draft
build: enable CA2007 enforcement via nested src/.editorconfig#5230jamescrosswell wants to merge 1 commit into
jamescrosswell wants to merge 1 commit into
Conversation
Move ConfigureAwait(false) enforcement (CA2007) from the legacy CodeAnalysis.ruleset to a nested src/.editorconfig. The .ruleset file no longer reliably enables CA2007 with current .NET SDKs (CA2007 is disabled by default), so the rule only fired in CI Release builds and was silently ignored locally in Rider and `dotnet build`. Using the modern dotnet_diagnostic.<id>.severity in a nested editorconfig under /src has two benefits: - it correctly activates rules that are disabled by default; - it naturally scopes the rule to library code only — tests, samples and benchmarks are unaffected, where awaiting without ConfigureAwait is fine and often more readable. Closes #2308 #skip-changelog Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5230 +/- ##
==========================================
+ Coverage 74.12% 74.13% +0.01%
==========================================
Files 508 508
Lines 18282 18282
Branches 3574 3574
==========================================
+ Hits 13551 13553 +2
+ Misses 3861 3860 -1
+ Partials 870 869 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Move
ConfigureAwait(false)enforcement (CA2007) from the legacysrc/CodeAnalysis.rulesetto a nestedsrc/.editorconfig.The ruleset file no longer reliably enables CA2007 with current .NET SDKs (CA2007 is disabled by default in modern .NET analyzers, and
<CodeAnalysisRuleSet>only overrides severity for rules that are already active). As a result, the rule only fired in CI Release builds and was silently ignored locally — both in Rider and withdotnet build— which is exactly the regression reported in #2308.Using
dotnet_diagnostic.CA2007.severity = errorinside a nested editorconfig under/srchas two advantages over the previous setup:ConfigureAwait(false)is unnecessary noise.Verification
Tested locally on macOS:
src/Sentry/Sentry.csprojin Debug → 0 errors.await sentryTask.ConfigureAwait(false);withawait sentryTask;inSpotlightHttpTransport.cs→ build fails with:net8.0,net9.0,net10.0). Reverted before commit.test/Sentry.Tests/Sentry.Tests.csprojwith its existingawait client.GetAsync(...);calls (noConfigureAwait) → 0 CA2007 errors, confirming the rule is correctly scoped to/srconly.Closes #2308
#skip-changelog